<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>JS寄生组合式继承</title>
	</head>

	<body>
		<script>
			//			function person(name){
			//				this.arr = ['wangwu','zhaoliu'];
			//				this.name = name;
			//			}
			//			person.prototype.showName = function(){
			//				return this.name;
			//			}
			//			function teacher(name){
			//				person.call(this,name);
			//			}
			//			teacher.prototype = new person();
			//			
			//			let o1 = new teacher('zhangsan');
			//			o1.arr.push('wula~');
			//			console.log(o1.name);
			//			console.log(o1.arr);
			//			let o2 = new teacher('lisi');
			//			console.log(o2.name);
			//			console.log(o2.arr);
			function person(name) {
				this.arr = ['wangwu', 'zhaoliu'];
				this.name = name;
			}
			person.prototype.showName = function() {
				return this.name;
			}

			function teacher(name) {
				person.call(this, name);
			}

			function object(o) {
				var g = function() {

				}
				g.prototype = o;
				return new g();
			}

			function inheritPrototype(subObj, superObj) {
				var proObj = object(superObj.prototype);
				proObj.constructor = subObj;
				subObj.prototype = proObj;
			}
			inheritPrototype(teacher, person);

			let o1 = new teacher('zhangsan');
			o1.arr.push('wula~');
			console.log(o1.name);
			console.log(o1.arr);
			let o2 = new teacher('lisi');
			console.log(o2.name);
			console.log(o2.arr);
		</script>
	</body>

</html>